//
//  IncubationSpacePublishCell.m
//  BigToBig
//
//  Created by yi liu on 16/8/8.
//  Copyright © 2016年 cn.cloudtp. All rights reserved.
//

#import "IncubationSpacePublishCell.h"

@implementation IncubationSpacePublishCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}


- (void)createSubViews{
    //  头像
    self.headImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, (kScreenWidth - 20)/6, (kScreenWidth - 20)/6)];
    self.headImageView.center = CGPointMake(self.headImageView.width / 2 + 10, 50);
    self.headImageView.image = [UIImage imageNamed:@"touxiang"];
    [self addSubview:self.headImageView];
    self.headImageView.layer.cornerRadius = (kScreenWidth - 20)/12;
    self.headImageView.layer.masksToBounds = YES;
    
    // 标题
    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.headImageView.maxX + 10, self.headImageView.y, kScreenWidth/2 - self.headImageView.maxX - 10, self.headImageView.height /3)];
    self.titleLabel.text = @"创业生态园";
    [self addSubview:self.titleLabel];
    self.titleLabel.textAlignment = NSTextAlignmentLeft;
    
    // 编辑按钮
    self.editButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.editButton.frame = CGRectMake(kScreenWidth - 10 - self.headImageView.width / 2, self.headImageView.y, self.headImageView.width / 2, self.headImageView.width / 2);
    
    [self addSubview:self.editButton];
    [self.editButton setImage:[UIImage imageNamed:@"edit"] forState:UIControlStateNormal];
    self.editButton.tintColor = [UIColor lightGrayColor];
    [self.editButton addTarget:self action:@selector(pushToPublishMessageViewController:) forControlEvents:UIControlEventTouchUpInside];
    
    // 描述
    self.describeLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.titleLabel.x, self.titleLabel.maxY + 5, kScreenWidth / 3 * 2, self.titleLabel.height)];
    [self addSubview:self.describeLabel];
    self.describeLabel.font = [UIFont systemFontOfSize:12];
    _describeLabel.textAlignment = 1;
    self.describeLabel.textColor = [UIColor lightGrayColor];

    
    
    // 定位图标
    UIImageView *positionImageView = [[UIImageView alloc]initWithFrame:CGRectMake(self.titleLabel.x, self.describeLabel.maxY + 5, self.headImageView.width / 7 * 2 , self.headImageView.width / 7 * 2 / 3 * 4)];
    positionImageView.image = [UIImage imageNamed:@"dingwei"];
    [self addSubview:positionImageView];
    
    // 定位地址
    self.positionLabel = [[UILabel alloc]initWithFrame:CGRectMake(positionImageView.maxX, positionImageView.y, kScreenWidth / 9 * 2 , positionImageView.height)];
    self.positionLabel.text = [NSString stringWithFormat:@" 北京"];
    self.positionLabel.font = [UIFont systemFontOfSize:12];
    self.positionLabel.textColor = [UIColor lightGrayColor];
    [self addSubview:self.positionLabel];
    
    // 电话图标
    UIImageView *phoneNumberImageView = [[UIImageView alloc]initWithFrame:CGRectMake(self.positionLabel.maxX, self.positionLabel.y, positionImageView.width, positionImageView.width)];
    phoneNumberImageView.image = [UIImage imageNamed:@"phone"];
    [self addSubview:phoneNumberImageView];
    
    // 已查看人数
    self.phoneNumberLabel = [[UILabel alloc]initWithFrame:CGRectMake(phoneNumberImageView.maxX, phoneNumberImageView.y, self.positionLabel.width , self.positionLabel.height)];
    self.phoneNumberLabel.text = [NSString stringWithFormat:@" 13240001617"];
    self.phoneNumberLabel.font = [UIFont systemFontOfSize:12];
    self.phoneNumberLabel.textColor = [UIColor lightGrayColor];
    [self addSubview:self.phoneNumberLabel];
    // 底层分割线
    UILabel *bottomLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 99, kScreenWidth, 1)];
    bottomLabel.backgroundColor = COLOR_RGBA(247, 247, 247, 1);
    [self addSubview:bottomLabel];
}

#pragma mark edit button 点击方法
- (void)pushToPublishMessageViewController:(UIButton *)button{
    [self.publishCellDelegate pushToPublishMessageViewControllerWithModel:nil];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
